// eslint-disable-next-line
import { BasicLayout, UserLayout } from '@/layouts'
import * as Icons from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [

  {
    path: '/',
    name: 'root',
    component: BasicLayout,
    children: [
      {
        path: '/channel',
        name: 'channel',
        component: () => import(/* webpackChunkName: "manage" */ '@/views/manage/user/Index'),
        meta: { title: '用户管理', icon: Icons.manage, permission: ['/channel'] }
      },
      {
        path: '/user',
        name: 'user',
        component: RouteView,
        meta: { title: '学员管理', icon: Icons.student, permission: ['/user'] },
        // component: () => import(/* webpackChunkName: "manage" */ '@/views/user/Index')
        children: [
          {
            path: '/user/list',
            component: () => import(/* webpackChunkName: "manage" */ '@/views/user/Index'),
            meta: { title: '学员列表', keepAlive: false, permission: ['/user/list'] }
          },
          {
            path: '/user/application',
            component: RouteView,
            meta: { title: '考培列表', keepAlive: false, permission: ['/user/application'] },
            children: [
              {
                path: '/user/application/audit',
                component: () => import(/* webpackChunkName: "manage" */ '@/views/user/application/Audit'),
                meta: { title: '待审核', keepAlive: false, permission: ['/user/application/audit'] }
              },
              {
                path: '/user/application/approved',
                component: () => import(/* webpackChunkName: "manage" */ '@/views/user/application/Approved'),
                meta: { title: '审核通过', keepAlive: false, permission: ['/user/application/approved'] }
              }
            ]
          }
        ]
      },
      {
        path: '/subject',
        name: 'subject',
        meta: { title: '工种管理', icon: Icons.subject, permission: ['/subject'] },
        component: () => import(/* webpackChunkName: "manage" */ '@/views/subject/Index')
      },
      {
        path: '/question',
        name: 'question',
        component: () => import(/* webpackChunkName: "store" */ '@/views/question/index/Index'),
        meta: { title: '题库管理', icon: Icons.question, permission: ['/question'] }
      },

      // 设置
      {
        path: '/setting',
        name: 'setting',
        component: () => import(/* webpackChunkName: "setting" */ '@/views/setting/Index'),
        meta: { title: '设置', icon: Icons.setting, permission: ['/setting'] }

      }
    ]
  },

// 更新账户信息
  {
    name: 'renew',
    path: '/manage',
    redirect: '/manage/renew',
    component: BasicLayout,
    hidden: true,
    meta: { title: '更新账户信息', keepAlive: false },
    children: [
      {
        path: 'renew',
        component: () => import(/* webpackChunkName: "manage" */ '@/views/manage/renew')
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [

  // 用户登录页
  {
    path: '/passport',
    component: UserLayout,
    redirect: '/passport/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "passport" */ '@/views/passport/Login')
      }
    ]
  },

  // 404页
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "exception" */ '@/views/exception/404')
  }

]
